package Day004.demo005_Math类;

/*
    Math类:  java.lang.Math 包, 该类中有很多静态方法 用与我们的数学运算
            public final class Math  不能继承

            常用方法:
                    1. public static int abs(int a) 获取参数a的绝对值：
                    2. public static double ceil(double a) 向上取整
                    3. public static double floor(double a) 向下取整
                    4. public static double pow(double a, double b) 获取a的b次幂
                    5. public static long round(double a) 四舍五入取整
                    6. public static int max(int a, int b) 最大值
                    7. public static int min(int a, int b) 最小值



 */

public class Test {
    public static void main(String[] args) {
        //1.绝对值
        System.out.println(Math.abs(-99));
        System.out.println(Math.abs(99));
        //2.向上取整
        System.out.println(Math.ceil(3.01213)); // 4.0
        System.out.println(Math.ceil(-3.01213)); // -3.0
        //3.向下取整
        System.out.println(Math.floor(3.999)); // 3.0
        System.out.println(Math.floor(-3.999)); // -4.0
        //4.获取a的b次幂
        System.out.println(Math.pow(3,2)); // 3^2  9.0
        //5.四舍五入取整
        System.out.println(Math.round(3.4)); // 3
        System.out.println(Math.round(3.5)); // 4
        //6.最大值
        System.out.println(Math.max(1,2)); // 2
        //7.最小值
        System.out.println(Math.min(1,2)); // 1

    }
}
